#import "SEGSuggestsaveManager.h"

#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif
#if __has_include(<Commom/SEGHTTPBusinessManager.h>)
#import <Commom/SEGHTTPBusinessManager.h>
#else
#import "SEGHTTPBusinessManager.h"
#endif

static id _SuggestSaveManager;
static dispatch_once_t onceToken;

@implementation SEGSuggestsaveManager
#pragma mark - SINGLE----BEGIN----
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _SuggestSaveManager = [[self alloc] init];
    });
    return _SuggestSaveManager;
}

+(void)destroyResource{
    onceToken = 0;
    _SuggestSaveManager = nil;
}

#pragma mark - SINGLE----END----

#pragma mark - HTTP----BEGIN----
-(void)requestSuggestsaveWithContext:(NSString*)context sugType:(NSString*)sugType finished:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))finished{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:context forKey:@"context"];
    [params setValue:sugType forKey:@"sugType"];
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-app/rest-api/v1/couster-suggest/save.json",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            finished(isSuccessed,nil,codeType,error.localizedDescription);
            return;
        }
        
        finished(isSuccessed,result,codeType,error.localizedDescription);
        return;
    }];
}
#pragma mark - HTTP----END----

#pragma mark - GETTER----BEGIN----
-(SEGSuggestsaveModel *)SuggestSave{
    if (!_SuggestSave) {
        _SuggestSave = [[SEGSuggestsaveModel alloc]init];
    }
    return _SuggestSave;
}
#pragma mark - GETTER----END----
@end

